package kosta.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class SessionInterceptor extends AbstractInterceptor {

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		String result = null;
		
		ActionContext ac = ActionContext.getContext();
		Map map = ac.getSession();
		
		String name = (String)map.get("name"); // = session.getAttribute("name");
		
		if(name == null){
			return Action.INPUT;
		}else{
			result = invocation.invoke();
			return result;
		}
		
	}

}
